{include file="public/nheader"}
<div class="layui-fluid layui-bg-white">
    <form action="{:url()}" class="layui-form layui-form-fixed">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>类型
            </label>
            <div class="layui-input-block">
                <input type="radio" name="type" lay-filter="type" value="3" {if !empty($row.type) &&
                    $row.type==3}checked{/if} title="区域代理">
                <input type="radio" name="type" lay-filter="type" value="5" {if !empty($row.type) &&
                    $row.type==5}checked{/if} title="划分代理">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>代理
            </label>
            <div class="layui-input-block">
                <select name="agentid" lay-search>
                    <option value="">请选择代理账号</option>
                    {foreach $agent as $v}
                    <option value="{$v.id}" {if !empty($row.agentid) && $row.agentid==$v.id}selected{/if}>
                        {$v.nickname}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item" id="provinceshow" {if !empty($row.type) && $row.type> 1}
            style="display:block"{else}style="display:none"{/if}>
            <label class="layui-form-label">
                <font color="red">* </font>省份
            </label>
            <div class="layui-input-block">
                <select name="province" data-area="" lay-filter="province" lay-search>
                    <option value="">请选择选择省份</option>
                    {foreach $province as $v}
                    <option value="{$v.area_code}" {if !empty($row.province) &&
                        $row.province==$v.area_code}selected{/if}>{$v.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item" id="cityshow" {if !empty($row.type) && $row.type> 1}
            style="display:block"{else}style="display:none"{/if}>
            <label class="layui-form-label">
                <font color="red">* </font>城市
            </label>
            <div class="layui-input-block">
                <select name="city" data-area="" lay-filter="city" lay-search>
                    <option value="">请选择选择城市</option>
                    {foreach $city as $v}
                    <option value="{$v.area_code}" {if !empty($row.city) && $row.city==$v.area_code}selected{/if}>
                        {$v.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item" id="areashow" {if !empty($row.type) && $row.type> 2}
            style="display:block"{else}style="display:none"{/if}>
            <label class="layui-form-label">
                <font color="red">* </font>区域
            </label>
            <div class="layui-input-block">
                <select name="area" data-area="" lay-filter="area" lay-search>
                    <option value="">请选择选择区域</option>
                    {foreach $area as $v}
                    <option value="{$v.area_code}" {if !empty($row.area) && $row.area==$v.area_code}selected{/if}>
                        {$v.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="layui-form-item" id="streetshow" {if !empty($row.type) && $row.type> 3}
            style="display:block"{else}style="display:none"{/if}>
            <label class="layui-form-label">
                <font color="red">* </font>街道
            </label>
            <div class="layui-input-block">
                <select name="street" data-area="" lay-filter="street">
                    <option value="">请选择选择街道</option>
                    {foreach $street as $v}
                    <option value="{$v.id}" {if !empty($row.street) && $row.street==$v.id}selected{/if}>
                        {$v.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="layui-footer layui-form-item layui-center ">
            <input type="hidden" value="{$row['id']|default='0'}" name="id" />
            <button class="layui-btn" lay-filter="submitIframe" type="button" lay-submit>提交</button>
            <button class="layui-btn layui-btn-primary" type="button" sa-event="closeDialog">取消</button>
        </div>
    </form>
</div>

{include file="public/nfooter"}
<script>
    layui.use(['form', 'layer', 'upload'], function () {
        $ = layui.jquery;
        var form = layui.form
            , upload = layui.upload
            , element = layui.element
            , layer = layui.layer;
        form.on('radio(type)', function (data) {
            var type = data.value;
            if (type == 1) {
                $('#provinceshow').hide();
                $('#cityshow').hide();
                $('#areashow').hide();
                $('#streetshow').hide();
            }
            if (type == 2) {
                $('#provinceshow').show();
                $('#cityshow').show();
                $('#areashow').hide();
                $('#streetshow').hide();
            }
            if (type == 3) {
                $('#provinceshow').show();
                $('#cityshow').show();
                $('#areashow').show();
                $('#streetshow').hide();
            }
            if (type == 4 || type == 5) {
                $('#provinceshow').show();
                $('#cityshow').show();
                $('#areashow').show();
                $('#streetshow').show();
            }
        });
    });
</script>